package ua.pp.bizon.yandex.api.impl;

import java.io.UnsupportedEncodingException;

import org.apache.http.HttpException;
import org.apache.http.entity.StringEntity;

import ua.pp.bizon.yandex.api.IHttpRemoteUtils;
import ua.pp.bizon.yandex.api.ObjectLookup;
import ua.pp.bizon.yandex.uploader.atom.AppLink;

public class GetToken {

	public String get(String username, String password) throws UnsupportedEncodingException, HttpException {
		return ObjectLookup.lookup(IHttpRemoteUtils.class).post(new StringEntity("grant_type=password&client_id=b765f9edc02c4171a95b7aee7bcf2ef7&username=" + username + "&password=" + password),new AppLink(new String("https://oauth.yandex.ru/token")), "application/x-www-form-urlencoded", null).substring(18, 50); 
		
	}

}
